package Experiment1;

/**
 * Created by zhangyunqi on 2017/9/25.
 */

import java.util.*;

public class ArrayListDemo {
    private Object[] obj;
    private int num;


    public boolean isEmpty(int o) {
        if (obj == null) {
            return true;
        }
        return false;
    }

    public void add(int index, Object element) {
        Object ob = null;
        for (int i = 0; i < obj.length; i++) {
            if (i == index) {
                ob = obj[i];
                obj[i] = element;
                for (int j = i + 1; j < obj.length + 1; j++) {
                    obj[j + 1] = obj[j];
                    obj[j] = ob;
                }
            }
        }
    }

    public boolean remove(Object o) {
        for (int i = 0; i < obj.length; i++) {
            if (obj[i].equals ( o )) {
                String str = obj.toString ();
                StringBuilder bd = new StringBuilder ( str );
                bd.deleteCharAt ( i );
                return true;
            }
        }
        return false;
    }

    public Object remove(int index) {
        for (int i = 0; i < obj.length; i++) {
            if (i == index) {
                StringBuilder bb = new StringBuilder ( obj.toString () );
                bb.deleteCharAt ( i );
            }
        }
        return obj;
    }

}
